import { DataTableOptions } from '@/components/form-designer/widget-panel/container-widgets'

export const basicFields = [
  {
    type: 'input',
    alias: '', //组件别名，可以自定义
    icon: 'text-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey: [], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      type: 'text',
      defaultValue: '',
      placeholder: '',
      columnWidth: '200px',
      size: '',
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      readonly: false,
      disabled: false,
      hidden: false,
      clearable: true,
      showPassword: false,
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      minLength: null,
      maxLength: null,
      showWordLimit: false,
      prefixIcon: '',
      suffixIcon: '',
      appendButton: false,
      appendButtonDisabled: false,
      buttonIcon: 'custom-search',
      appendText: false,
      textForAppend: '',
      //-------------------
      onCreated: '',
      onMounted: '',
      onInput: '',
      onChange: '',
      onFocus: '',
      onBlur: '',
      onValidate: '',
      onAppendButtonClick: '',
    },
  },

  {
    type: 'textarea',
    icon: 'textarea-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey: [], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      rows: 3,
      autosize: false, //自适应内容高度
      defaultValue: '',
      placeholder: '',
      columnWidth: '200px',
      size: '',
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      readonly: false,
      disabled: false,
      hidden: false,
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      minLength: null,
      maxLength: null,
      showWordLimit: false,
      //-------------------
      onCreated: '',
      onMounted: '',
      onInput: '',
      onChange: '',
      onFocus: '',
      onBlur: '',
      onValidate: '',
    },
  },

  {
    type: 'number',
    icon: 'number-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey: [], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      defaultValue: 0,
      placeholder: '',
      columnWidth: '200px',
      size: '',
      controls: true, //是否显示控制按钮
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      disabled: false,
      hidden: false,
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      formulaEnabled: false, // 启用计算公式
      formula: '', // 计算公式
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      min: -100000000000,
      max: 100000000000,
      precision: 0,
      step: 1,
      controlsPosition: 'right',
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onFocus: '',
      onBlur: '',
      onValidate: '',
    },
  },

  {
    type: 'radio',
    icon: 'radio-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey: [], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      defaultValue: null,
      columnWidth: '200px',
      size: '',
      displayStyle: 'inline',
      buttonStyle: false,
      border: false,
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      disabled: false,
      hidden: false,
      dsEnabled: false, // 是否使用数据源数据
      dsName: '', // 数据源名称
      dataSetName: '', //数据集名称
      labelKey: 'label',
      valueKey: 'value',
      optionValueType: '',
      optionItems: [],
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      //-------------------
      service: {
        enabled: true,
        id: '',
      },
      autoLoad: true,
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onValidate: '',
    },
  },

  {
    type: 'checkbox',
    icon: 'checkbox-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey: [], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      defaultValue: [],
      columnWidth: '200px',
      size: '',
      displayStyle: 'inline',
      buttonStyle: false,
      border: false,
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      disabled: false,
      hidden: false,
      dsEnabled: false, // 是否使用数据源数据
      dsName: '', // 数据源名称
      dataSetName: '', //数据集名称
      labelKey: 'label',
      valueKey: 'value',
      optionValueType: '',
      optionItems: [],
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      //-------------------
      service: {
        enabled: true,
        id: '',
      },
      autoLoad: true,
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onValidate: '',
    },
  },

  {
    type: 'select',
    icon: 'select-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey: [], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      defaultValue: '',
      placeholder: '',
      columnWidth: '200px',
      size: '',
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      disabled: false,
      hidden: false,
      clearable: true,
      filterable: false,
      // allowCreate: false,
      remote: false,
      // automaticDropdown: false,  //自动下拉
      multiple: false,
      multipleLimit: 0,
      collapseTags: false, //对多选折叠已选项
      dsEnabled: false, // 是否使用数据源数据
      dsName: '', // 数据源名称
      dataSetName: '', //数据集名称
      labelKey: 'label',
      valueKey: 'value',
      optionValueType: '',
      optionItems: [],
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      service: {
        enabled: true,
        id: '',
      },
      autoLoad: true,
      //-------------------
      onCreated: '',
      onMounted: '',
      onRemoteQuery: '',
      onChange: '',
      onFocus: '',
      onBlur: '',
      onValidate: '',
    },
  },

  {
    type: 'time',
    icon: 'time-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey: [], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      defaultValue: null,
      placeholder: '',
      columnWidth: '200px',
      size: '',
      autoFullWidth: true,
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      readonly: false,
      disabled: false,
      hidden: false,
      clearable: true,
      editable: false,
      format: 'HH:mm:ss', //时间格式
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onFocus: '',
      onBlur: '',
      onValidate: '',
    },
  },

  {
    type: 'time-range',
    icon: 'time-range-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey: [], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      defaultValue: null,
      startPlaceholder: '',
      endPlaceholder: '',
      columnWidth: '200px',
      size: '',
      autoFullWidth: true,
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      readonly: false,
      disabled: false,
      hidden: false,
      clearable: true,
      editable: false,
      format: 'HH:mm:ss', //时间格式
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onFocus: '',
      onBlur: '',
      onValidate: '',
    },
  },

  {
    type: 'date',
    icon: 'date-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey: [], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      type: 'date',
      defaultValue: null,
      placeholder: '',
      columnWidth: '200px',
      size: '',
      autoFullWidth: true,
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      readonly: false,
      disabled: false,
      hidden: false,
      clearable: true,
      editable: false,
      format: 'YYYY-MM-DD', //日期显示格式
      valueFormat: '', //日期对象格式
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onFocus: '',
      onBlur: '',
      onValidate: '',
    },
  },

  {
    type: 'date-range',
    icon: 'date-range-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey: [], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      type: 'daterange',
      defaultValue: null,
      startPlaceholder: '',
      endPlaceholder: '',
      columnWidth: '200px',
      size: '',
      autoFullWidth: true,
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      readonly: false,
      disabled: false,
      hidden: false,
      clearable: true,
      editable: false,
      format: 'YYYY-MM-DD', //日期显示格式
      valueFormat: 'YYYY-MM-DD', //日期对象格式
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onFocus: '',
      onBlur: '',
      onValidate: '',
    },
  },

  {
    type: 'switch',
    icon: 'switch-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey:[], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      modelSelect: '',
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      defaultValue: null,
      columnWidth: '200px',
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      disabled: false,
      hidden: false,
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      switchWidth: 40,
      activeText: '',
      inactiveText: '',
      activeColor: null,
      inactiveColor: null,
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onValidate: '',
    },
  },

  {
    type: 'rate',
    icon: 'rate-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey:[], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      defaultValue: null,
      columnWidth: '200px',
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      disabled: false,
      hidden: false,
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      max: 5,
      lowThreshold: 2,
      highThreshold: 4,
      allowHalf: false,
      showText: false,
      showScore: false,
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onValidate: '',
    },
  },

  {
    type: 'color',
    icon: 'color-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey:[], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      defaultValue: null,
      columnWidth: '200px',
      size: '',
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      disabled: false,
      hidden: false,
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onValidate: '',
    },
  },

  {
    type: 'slider',
    icon: 'slider-field',
    formItemFlag: true,
    options: {
      name: '',
      serviceFieldKey:[], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      keyNameEnabled: false,
      keyName: '', //数据键值名称
      label: '',
      labelAlign: '',
      columnWidth: '200px',
      showStops: true,
      size: '',
      labelWidth: null,
      labelHidden: false,
      labelWrap: false, //标签超长换行
      disabled: false,
      hidden: false,
      required: false,
      requiredHint: '',
      validation: '',
      validationHint: '',
      //-------------------
      customClass: '', //自定义css类名
      labelIconClass: null,
      labelIconPosition: 'rear',
      labelTooltip: null,
      min: 0,
      max: 100,
      step: 10,
      range: false,
      //vertical: false,
      height: null,
      //-------------------
      onCreated: '',
      onMounted: '',
      onChange: '',
      onValidate: '',
    },
  },

  {
    type: 'static-text',
    icon: 'static-text',
    formItemFlag: false,
    options: {
      name: '',
      serviceFieldKey:[], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      columnWidth: '200px',
      hidden: false,
      textContent: 'static text',
      textAlign: 'left',
      fontSize: '13px',
      preWrap: false, //是否自动换行
      //-------------------
      customClass: '', //自定义css类名
      //-------------------
      onCreated: '',
      onMounted: '',
    },
  },

  {
    type: 'html-text',
    icon: 'html-text',
    formItemFlag: false,
    options: {
      name: '',
      serviceFieldKey:[], //服务数据绑定键值
      modelSelectFieldKey: [], // 模型匹配模式
      columnWidth: '200px',
      hidden: false,
      htmlContent: '<b>html text</b>',
      //-------------------
      customClass: '', //自定义css类名
      //-------------------
      onCreated: '',
      onMounted: '',
    },
  },

  {
    type: 'button',
    icon: 'button',
    formItemFlag: false,
    options: {
      name: '',
      label: '',
      columnWidth: '200px',
      size: '',
      displayStyle: 'block',
      disabled: false,
      hidden: false,
      type: '',
      plain: false,
      round: false,
      circle: false,
      isSubmit: false,
      icon: null,
      //-------------------
      customClass: '', //自定义css类名
      postKey: '', //如果是提交按钮，需要提交哪个svvoId
      //-------------------
      onCreated: '',
      onMounted: '',
      onClick: '',
      onSubmit: '',
    },
  },

  {
    type: 'divider',
    icon: 'divider',
    formItemFlag: false,
    options: {
      name: '',
      label: '',
      columnWidth: '200px',
      direction: 'horizontal',
      contentPosition: 'center',
      hidden: false,
      //-------------------
      customClass: '', //自定义css类名
      //-------------------
      onCreated: '',
      onMounted: '',
    },
  },
]

export type InputFieldOptions = (typeof basicFields[0]['options'])
export type TextareaFieldOptions = typeof basicFields[1]['options']
export type NumberFieldOptions = typeof basicFields[2]['options']
export type RadioFieldOptions = typeof basicFields[3]['options']
export type CheckboxFieldOptions = typeof basicFields[4]['options']
export type SelectFieldOptions = typeof basicFields[5]['options']
export type TimeFieldOptions = typeof basicFields[6]['options']
export type TimeRangeFieldOptions = typeof basicFields[7]['options']
export type DateFieldOptions = typeof basicFields[8]['options']
export type DateRangeFieldOptions = typeof basicFields[9]['options']
export type SwitchFieldOptions = typeof basicFields[10]['options']
export type RateFieldOptions = typeof basicFields[11]['options']
export type ColorFieldOptions = typeof basicFields[12]['options']
export type SliderFieldOptions = typeof basicFields[13]['options']
export type StaticTextFieldOptions = typeof basicFields[14]['options']
export type HtmlTextFieldOptions = typeof basicFields[15]['options']
export type ButtonFieldOptions = typeof basicFields[16]['options']
export type DividerFieldOptions = typeof basicFields[17]['options']

// Define types for each complete field configuration
export type InputField = typeof basicFields[0]
export type TextareaField = typeof basicFields[1]
export type NumberField = typeof basicFields[2]
export type RadioField = typeof basicFields[3]
export type CheckboxField = typeof basicFields[4]
export type SelectField = typeof basicFields[5]
export type TimeField = typeof basicFields[6]
export type TimeRangeField = typeof basicFields[7]
export type DateField = typeof basicFields[8]
export type DateRangeField = typeof basicFields[9]
export type SwitchField = typeof basicFields[10]
export type RateField = typeof basicFields[11]
export type ColorField = typeof basicFields[12]
export type SliderField = typeof basicFields[13]
export type StaticTextField = typeof basicFields[14]
export type HtmlTextField = typeof basicFields[15]
export type ButtonField = typeof basicFields[16]
export type DividerField = typeof basicFields[17]

export type FieldType =
  | 'input' | 'textarea' | 'number' | 'radio' | 'checkbox'
  | 'select' | 'time' | 'time-range' | 'date' | 'date-range'
  | 'switch' | 'rate' | 'color' | 'slider' | 'static-text'
  | 'html-text' | 'button' | 'divider' | 'data-table';

export type FieldOptionsMap = {
  'input': InputFieldOptions;
  'textarea': TextareaFieldOptions;
  'number': NumberFieldOptions;
  'radio': RadioFieldOptions;
  'checkbox': CheckboxFieldOptions;
  'select': SelectFieldOptions;
  'time': TimeFieldOptions;
  'time-range': TimeRangeFieldOptions;
  'date': DateFieldOptions;
  'date-range': DateRangeFieldOptions;
  'switch': SwitchFieldOptions;
  'rate': RateFieldOptions;
  'color': ColorFieldOptions;
  'slider': SliderFieldOptions;
  'static-text': StaticTextFieldOptions;
  'html-text': HtmlTextFieldOptions;
  'button': ButtonFieldOptions;
  'divider': DividerFieldOptions;
  'data-table': DataTableOptions;
}
export type FieldMap = {
  'input': InputField;
  'textarea': TextareaField;
  'number': NumberField;
  'radio': RadioField;
  'checkbox': CheckboxField;
  'select': SelectField;
  'time': TimeField;
  'time-range': TimeRangeField;
  'date': DateField;
  'date-range': DateRangeField;
  'switch': SwitchField;
  'rate': RateField;
  'color': ColorField;
  'slider': SliderField;
  'static-text': StaticTextField;
  'html-text': HtmlTextField;
  'button': ButtonField;
  'divider': DividerField;
}
// 定义泛型类型 FieldWidget
export type FieldWidgetType<T extends FieldType> = {
  type: T;
} & (T extends keyof FieldMap ? FieldMap[T] : never);
